// 建议dispatch/commit调用，均采用如下形式包裹一层，以启用类型推导

import store from './index';
import {InterfaceUser} from '@/interface/InterfaceUser';
import * as types from './mutation-types';


export const updateUser = (user: any | InterfaceUser) => {
    return store.commit(types.USER_UPDATE, user);
};

export const exitUser = () => {
    return store.commit(types.USER_EXIT);
};

export const deviceReady = () => {
    return store.commit(types.DEVICE_READY);
};
export const wechatReady = (status: boolean) => {
    return store.commit(types.WECHAT_READY, status);
};
export const updateVersionCode = (code: string) => {
    return store.commit(types.UPDATE_VERSION_CODE, code);
};
export const updateVersionName = (name: string) => {
    return store.commit(types.UPDATE_VERSION_NAME, name);
};

export const settingDownload = (value: boolean) => {
    return store.commit(types.SETTING_UPDATE_DOWNLOAD);
};

export const changeNoReadCount = (count: number) => {
    return store.commit(types.CHANGE_NO_READ_COUNT, count);
};

export const updateDataCache = (data: any) => {
    return store.commit(types.DATA_CACHE_UPDATE, data);
};

export const removeDataCache = (key: string) => {
    return store.commit(types.DATA_CACHE_REMOVE, key);
};

export const clearDataCache = () => {
    return store.commit(types.DATA_CACHE_CLEAR);
};

export const shareControllerToggle = (param: any={}) => {
    return store.commit(types.SHARE_CONTROLLER_TOGGLE, param);
};

//
// export const dispatchAddToCart = (product: Product) => {
//   return store.dispatch('addToCart', product)
// }
